import axios from 'axios';
import * as actionTypes from './actionTypes';
import { fromJS } from 'immutable';

const changeLogin = () => ({
	type: actionTypes.CHANGE_LOGIN
})

export const login = (accout, password) => {
	return (dispatch) => {
		axios.get('/mock/login.json?accout=' + accout + '&password=' + password)
		.then(res => {
			const result = res.data.data;
			if (result) {
				dispatch(changeLogin());
			} else {
				console.log('登陆失败');
			}
		});
	}
}

export const logout = () => ({
	type: actionTypes.CHANGE_LOGOUT
})